//
//  ContactView.m
//  UI10_homework通讯录UI
//
//  Created by dllo on 16/6/19.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "ContactView.h"

//@interface ContactView ()
//
//@property(nonatomic, retain)UIImage *headerImage;
//@property(nonatomic, assign)NSInteger teleNumber;
//@property(nonatomic, assign)NSInteger qNumber;
//@property(nonatomic, retain)NSArray *contentsArray;
//@property(nonatomic, retain)NSString *cName;
//
//@end



@implementation ContactView

-(void)dealloc{
    [_headerImage release];
    [_contentsArray release];
    [_enterInArray release];
    [super dealloc];
    
}



//-(instancetype)initWithFrame:(CGRect)frame withImage:(UIImage *)headerImage withName:(NSString *)name withNumber:(NSInteger)teleNumber withQNumber:(NSInteger)qNumber{
-(instancetype)initWithFrame:(CGRect)frame{
    
    if (self = [super initWithFrame:frame]) {
        
        self.contentsArray = [NSArray array];
        self.enterInArray = [NSArray array];
        [self creatSubs];
    }
    return self;
}

-(void)creatSubs{
    
    //创建头像
    UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(CGRectGetWidth(self.frame) / 4, 84, CGRectGetWidth(self.frame) / 5, CGRectGetHeight(self.frame) / 7)];
    imageView.image = self.headerImage;
        [self addSubview:imageView];
    
    // 创建Label;
    for (int i = 0; i < self.contentsArray.count; i++) {
        
        UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(30, (i + 1) * CGRectGetHeight(self.bounds) / 8 * 3, 100, 80)];
        label.text = self.contentsArray[i];
        [self addSubview:label];
        [label release];
        
    }
    
    // 创建textField
    for (int i = 0; i < self.enterInArray.count; i ++) {
        UITextField *textField = [[UITextField alloc]initWithFrame:CGRectMake(190, (i + 1) * CGRectGetHeight(self.bounds) / 8 * 3, 100, 80)];
        
        textField.text = self.enterInArray[i];
        [self addSubview:textField];
        [textField release];
    }
    
  
}



-(void)setContentsArray:(NSArray *)contentsArray{
    
    if (_contentsArray != contentsArray) {
        [_contentsArray release];
        _contentsArray = [contentsArray retain];
    }
    
    [self creatSubs];

    
}

-(void)setEnterInArray:(NSArray *)enterInArray{
    
    if (_enterInArray != enterInArray) {
        [_enterInArray release];
        _enterInArray = [enterInArray retain];
    }
    [self creatSubs];

}




@end
